/*
 *  Copyright 2024 Collate.
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *  http://www.apache.org/licenses/LICENSE-2.0
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
@import (reference) '../../styles/variables.less';

@keyframes resize-show-animation {
  from {
    height: 0px;
    padding: 0 16px;
  }
  to {
    height: max-content;
    padding: 8px 16px;
  }
}

@keyframes resize-hide-animation {
  from {
    height: max-content;
    padding: 8px 16px;
  }
  to {
    height: 0px;
    padding: 0 16px;
  }
}

.alert-container {
  height: 0px;
  color: @alert-text-color;
  border: 1px solid;

  .alert-message {
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Limits to 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 3em; /* Approx height for 2 lines */
    transition: max-height 0.3s ease;
  }

  .alert-message.expanded {
    -webkit-line-clamp: unset;
    max-height: none;
  }

  .alert-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    text-decoration: underline;
  }

  #alert-icon {
    font-size: 20px;
    border-radius: 50%;
    padding: 8px;
  }

  &.show-alert {
    animation: resize-show-animation 0.3s ease-in-out forwards;
    display: flex;
    align-items: center;
    border-radius: 12px;
    margin-bottom: 12px;
  }

  &.hide-alert {
    animation: resize-hide-animation 0.2s ease-in-out forwards;
  }

  &.info {
    background-color: @alert-info-bg;
    border-color: @alert-info;

    #alert-icon {
      background-color: @alert-info-icon-bg-1;
      border: 6px solid @alert-info-icon-bg-2;
    }
  }

  &.grey-info {
    background-color: @grey-9;
    border-color: @grey-15;
    border-radius: @border-rad-xs;

    /* Shadows/shadow-xs */
    box-shadow: 0px 1px 2px 0px rgba(10, 13, 18, 0.05);

    #alert-icon {
      background-color: @white;
      border: 1px solid @grey-15;
      border-radius: @border-rad-xs;
      color: @grey-700;

      /* Shadows/shadow-xs-skeuomorphic */
      box-shadow: 0px 0px 0px 1px rgba(10, 13, 18, 0.18) inset,
        0px -2px 0px 0px rgba(10, 13, 18, 0.05) inset,
        0px 1px 2px 0px rgba(10, 13, 18, 0.05);
    }
  }

  &.success {
    background-color: @alert-success-bg;
    border-color: @alert-success;
  }

  &.warning {
    background-color: @alert-warning-bg;
    border-color: @alert-warning;

    #alert-icon {
      background-color: @alert-warning-icon-bg-1;
      border: 6px solid @alert-warning-icon-bg-2;
    }
  }

  &.error {
    background-color: @alert-error-bg;
    border-color: @alert-error;

    #alert-icon {
      background-color: @alert-error-icon-bg-1;
      border: 6px solid @alert-error-icon-bg-2;
    }
  }

  .ant-alert-description {
    font-size: 14px;
    line-height: 20px;
    text-align: left;
    font-weight: 600;
  }

  .alert-close-icon {
    display: flex;
    align-items: center;
    width: 10px;
    height: 10px;
    margin-right: 13px;
  }

  &.custom-alert-description {
    .ant-alert-description {
      font-weight: 400;
    }
  }
}
